package  
{
	import net.flashpunk.Entity;
	import net.flashpunk.FP;
	import net.flashpunk.graphics.Text;
	import net.flashpunk.tweens.misc.VarTween;
	import net.flashpunk.utils.Ease;

	
	/**
	 * ...
	 * @author Donatello
	 */
	public class Dialog extends Entity
	{
		private var tweenY:VarTween;
		private var tweenAlpha:VarTween;
		private var text:Text;
		private var vel:Number;
		
		public function Dialog(texto:String,px:Number,py:Number,v:Number,yfinal:Number) 
		{
			
			text = new Text(texto);
			text.x =px;
			text.y = py;
			text.alpha = 1;
			
			vel = v;
			
			tweenY = new VarTween();
			tweenAlpha = new VarTween();
			
			tweenY.tween(text, "y",yfinal, vel);
			
			graphic = text;
			
			addTween(tweenY);
			addTween(tweenAlpha);
			
		}
		override public function update():void
		{
			
			if(tweenY.percent>=0.75)
			{
				tweenAlpha.tween(text, "alpha", 0, 0.5);
			}
			
			if (tweenAlpha.percent == 1)
				FP.world.remove(this);
			
		}
	}

}